import 'package:flutter/material.dart';

class ProductIntroductionDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(title: Text("ProductIntroductionDemo")),
      body: Column(
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          _buildTitle(),
          _buildDescription(),
          _buildRatingView(),
          _buildActionbar(),
        ],
      ),
    );
  }

  Widget _buildTitle() {
    TextStyle style = new TextStyle(
      fontSize: 20,
      fontWeight: FontWeight.bold,
    );
    return Container(
      margin: EdgeInsets.fromLTRB(0, 20, 0, 0),
      color: Colors.tealAccent,
      child: Text(
        "嵌套行和列",
        style: style,
        textAlign: TextAlign.center,
      ),
    );
  }

  Widget _buildDescription() {
    TextStyle style = new TextStyle(
      fontSize: 14,
      fontWeight: FontWeight.normal,
    );
    return Container(
      margin: EdgeInsets.fromLTRB(0, 20, 0, 0),
      color: Colors.tealAccent,
//      child: Center(
        child: Text(
          "要在Flutter中创建行或列，可以将一个widget列表添加到Row 或Column 中。 同时，每个孩子本身可以是一个Row或一个Column，依此类推。以下示例显示如何在行或列内嵌套行或列。",
          style: style,
          textAlign: TextAlign.center,
        ),
//      ),
    );
  }

  Widget _buildRatingView() {
    return Container(
      margin: EdgeInsets.fromLTRB(0, 20, 0, 0),
      color: Colors.tealAccent,
      child: Row(
//        mainAxisAlignment: MainAxisAlignment.spaceEvenly,
      mainAxisAlignment: MainAxisAlignment.center,
//      mainAxisAlignment: MainAxisAlignment.spaceBetween,
//      mainAxisAlignment: MainAxisAlignment.spaceAround,
//        mainAxisAlignment: MainAxisAlignment.start,
        children: <Widget>[
          _buildRatingStars(),
          _buildRationgLabel(),
        ],
      ),
    );
  }

  Widget _buildRatingStars() {
    return Container(
        color: Colors.teal,
        child: Row(
          mainAxisSize: MainAxisSize.min,
          children: <Widget>[
            Icon(Icons.star),
            Icon(Icons.star),
            Icon(Icons.star),
            Icon(Icons.star),
            Icon(Icons.star),
          ],
        ));
  }

  Widget _buildRationgLabel() {
    return Container(
      color: Colors.amber,
      child: Text("170 Reviews"),
      margin: EdgeInsets.fromLTRB(20, 0, 0, 0),
    );
  }

  Widget _buildActionbar() {
    return Container(
      color: Colors.tealAccent,
      margin: EdgeInsets.fromLTRB(0, 10, 0, 0),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          _buildActionBarItem(Icons.ac_unit, "PREF", "25min"),
          _buildActionBarItem(Icons.account_balance_wallet, "COOK", "25min"),
          _buildActionBarItem(Icons.add_call, "FEEDS", "25min"),
        ],
      ),
    );
  }

  Widget _buildActionBarItem(IconData icon, String title, String subTitle) {
    return Container(
        padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            Icon(icon),
            Text(
              title,
              style: new TextStyle(fontSize: 14, fontWeight: FontWeight.w400),
            ),
            Text(
              subTitle,
              style: new TextStyle(fontSize: 12, fontWeight: FontWeight.w200),
            ),
          ],
        ));
  }
}
